﻿function ClientAddResourceType() {
    Url = Portal.OfficeMan.ResourceType.GetAddUrl().value;
    window.open(Url, '_self');
    //ClientReading();
}

function ClientSaveAddResourceType() {
    ResourceTypeName = document.getElementById("txtResourceTypeName").value;

    RetValue = Portal.OfficeMan.AddResourceType.ServerSideAddResourceType(ResourceTypeName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    document.getElementById("txtResourceTypeName").value = "";
    document.getElementById("txtResourceTypeName").focus();
    //window.close();
}

function ClientUpdateResourceType(ResourceTypeId) {
    Url = Portal.OfficeMan.ResourceType.GetUpdateUrl(ResourceTypeId).value;
    window.open(Url, '_self');
    //ClientReading();
}

function ClientDeleteResourceType(ResourceTypeId)
{
    Msg=Portal.OfficeMan.ResourceType.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.OfficeMan.ResourceType.ServerSideDeleteResourceType(ResourceTypeId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    ClientReading();
}



function ShowClientUpdateUrlForm(ResourceTypeId)
{
    Url = Portal.OfficeMan.ResourceType.GetUpdateUrl(ResourceTypeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.open(Url, '_self'); 
}


function ClientSaveUpdateResourceType(ResourceTypeId)
{
    ResourceTypeName = document.getElementById("txtResourceTypeName").value;

    RetValue = Portal.OfficeMan.UpdateResourceType.ServerSideUpdateResourceType(ResourceTypeId, ResourceTypeName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.open('default.aspx?WebPartId=ResourceType','_self');
}

function ClientReading() {
   document.getElementById("divProcessing").innerHTML = Portal.OfficeMan.ResourceType.GetProcessingText().value;
   setTimeout("RealClientReading()",10);
}

function RealClientReading() {
    rValue = Portal.OfficeMan.ResourceType.GetResourceType().value;
    document.getElementById("divResourceTypeContent").innerHTML = rValue;
    document.getElementById("divProcessing").innerHTML = "";
}
